<template>
  <div class="auth-container" :class="{ 'dark-mode': isDarkMode }">
    <div class="background">
      <div class="background-overlay"></div>
    </div>
    
    <div class="auth-content">
      <div class="auth-card">
        <div class="auth-header">
          <div class="logo-container">
            <img src="../assets/logo.png" alt="智慧农业" class="logo" />
          </div>
          <h2 class="title">智慧农业信息系统</h2>
          <p class="subtitle">现代化农业生产管理平台</p>
        </div>
        
        <div class="auth-body">
          <router-view v-slot="{ Component }">
            <transition name="fade-transform" mode="out-in">
              <component :is="Component" />
            </transition>
          </router-view>
        </div>
        
        <div class="auth-footer">
          <p>© {{ currentYear }} 智慧农业信息系统 版权所有</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, computed } from 'vue';

// 当前年份
const currentYear = new Date().getFullYear();

// 主题模式
const isDarkMode = ref(false);

// 组件挂载时设置主题
onMounted(() => {
  const storedTheme = localStorage.getItem('theme');
  isDarkMode.value = storedTheme === 'dark';
  applyTheme();
});

// 切换主题
function toggleTheme() {
  localStorage.setItem('theme', isDarkMode.value ? 'dark' : 'light');
  applyTheme();
}

// 应用主题
function applyTheme() {
  document.documentElement.setAttribute('data-theme', isDarkMode.value ? 'dark' : 'light');
}
</script>

<style scoped>
.auth-container {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.background {
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: url('https://images.unsplash.com/photo-1500382017468-9049fed747ef?w=1920&auto=format&fit=crop');
  background-size: cover;
  background-position: center;
  z-index: -2;
}

.background-overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(32, 95, 38, 0.8) 0%, rgba(0, 128, 0, 0.6) 100%);
  z-index: -1;
}

.auth-content {
  width: 100%;
  max-width: 500px;
  padding: 0 20px;
  z-index: 1;
}

.auth-card {
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.auth-header {
  padding: 30px 20px 20px;
  text-align: center;
  background: linear-gradient(to right, #367834, #52af4c);
  color: white;
}

.logo-container {
  margin-bottom: 16px;
}

.logo {
  height: 60px;
}

.title {
  font-size: 24px;
  font-weight: bold;
  margin: 0 0 8px;
}

.subtitle {
  font-size: 16px;
  opacity: 0.8;
  margin: 0;
}

.auth-body {
  padding: 30px;
}

.auth-footer {
  padding: 16px 30px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--el-text-color-secondary);
}

/* 深色模式 */
.auth-container.dark-mode .auth-card {
  background-color: rgba(33, 33, 33, 0.85);
  color: #f5f5f5;
}

.auth-container.dark-mode .auth-footer {
  border-top-color: rgba(255, 255, 255, 0.1);
  color: #aaa;
}

/* 过渡动画 */
.fade-transform-enter-active,
.fade-transform-leave-active {
  transition: all 0.3s;
}

.fade-transform-enter-from {
  opacity: 0;
  transform: translateY(20px);
}

.fade-transform-leave-to {
  opacity: 0;
  transform: translateY(-20px);
}

/* 响应式布局 */
@media (max-width: 576px) {
  .auth-content {
    padding: 0 10px;
  }
  
  .auth-header {
    padding: 20px 15px 15px;
  }
  
  .logo {
    height: 50px;
  }
  
  .auth-body {
    padding: 20px;
  }
  
  .auth-footer {
    padding: 12px 20px;
    flex-direction: column;
    gap: 10px;
  }
}
</style> 